home *** CD-ROM | disk | FTP | other *** search
- unit Manyu;
-
- interface
-
- uses
- SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
- Forms, Dialogs, StdCtrls, Menus;
-
- type
- TForm1 = class(TForm)
- MainMenu1: TMainMenu;
- Help1: TMenuItem;
- About1: TMenuItem;
- Button1: TButton;
- Button2: TButton;
- Edit1: TEdit;
- procedure Button1Click(Sender: TObject);
- procedure Button2Click(Sender: TObject);
- procedure About1Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- uses TypInfo;
-
- {$R *.DFM}
-
- procedure ActivateControls(SetTo: Boolean;
- const ControlsToChange: array of const);
- var
- I: integer;
- PropInfo: PPropInfo;
- begin
- for I := Low(ControlsToChange) to High(ControlsToChange) do
- with TVarRec(ControlsToChange[I]) do
- { Sanity check to see if it is an object }
- if VType = vtObject then
- begin
- PropInfo := GetPropInfo(VObject.ClassInfo, 'Enabled');
- if Assigned(PropInfo) then
- SetOrdProp(VObject, PropInfo, LongInt(SetTo));
- end;
- end;
-
- procedure TForm1.Button1Click(Sender: TObject);
- begin
- ActivateControls(False, [Button1, Edit1, About1]);
- end;
-
- procedure TForm1.Button2Click(Sender: TObject);
- begin
- ActivateControls(True, [Button1, Edit1, About1]);
- end;
-
- procedure TForm1.About1Click(Sender: TObject);
- begin
- MessageDlg('About Box', mtInformation, [mbOk], 0);
- end;
-
- end.
-